﻿using Algorithms.Common.Helpers;
using Dqaqs.ProfileTableAlgorithm.Helpers;
using NUnit.Framework;

namespace Dqaqs.ProfileTableAlgorithm
{
	[TestFixture]
	public class ProfTableImplUnitTests
	{
		[Test]
		public void TableHelperReorderColumn()
		{
			const string dataTxt = "Brand_s,Model_s,Price_s|Sony,Powershot,Exp";
			var init = UnitTestsDataTableHelper.DataTableFromString(dataTxt);
			var result = TableHelper.ReordrColumns(init, new[] {"Price", "Brand", "Model"});
			var resulstStr = UnitTestsDataTableHelper.DataTableToString(result);
			const string orderedDat = "Price_s,Brand_s,Model_s|Exp,Sony,Powershot";
			Assert.That(resulstStr, Is.EqualTo(orderedDat));
		}

		[Test]
		public void EpsilonReducerReduction()
		{
			var svc = new EpsilonReducerService("g");
			const string dataTxt =
				"g_i,B_s,M_s,P_s,Q(P.A)_d|" +
				"7,,,,0.8|" +
				"3,C,,,0.7|" +
				"1,C,N,,0.6|" +
				"0,C,N,L,0.7|" +
				"1,C,S,,0.2|" +
				"0,C,S,H,0.9|" +
				"0,C,S,L,0.2";
			var init = UnitTestsDataTableHelper.DataTableFromString(dataTxt);

			var result = svc.ReduceData(init, 0.21);
			var resultStr = UnitTestsDataTableHelper.DataTableToString(result);

			const string expTxt =
				"g_i,B_s,M_s,P_s,Q(P.A)_d|" +
				"7,,,,0.8|" +
				"1,C,S,,0.2|" +
				"0,C,S,H,0.9";
			Assert.That(resultStr, Is.EqualTo(expTxt));
		}

	}
}
